@extends('index.app')

@section('content')
    <ol class="breadcrumb">
        <li><a href="{{url('/')}}">首页</a></li>
        <li class="active">失物招领</li>
    </ol>
    <div class="panel panel-default">
        <div class="panel-heading">
            <form class="form-horizontal" action="{{url('item')}}">
                <div class="form-group">
                    <label class="col-sm-1 control-label">类型</label>

                    <div class="col-sm-2">
                        <select name="type" class="selectpicker" data-width="150">
                            <option></option>
                            @foreach($types as $type => $name)
                                <option value="{{$type}}" <?=old('type') == $type ? 'selected' : ''?>>{{$name}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">地点</label>

                    <div class="col-sm-2">
                        <select name="province_id" class="selectpicker" data-width="150" data-toggle="selectpicker"
                                data-nextselect="#city_id" data-refurl="{{url('api/area/areas?id=')}}{value}"
                                data-type="get">
                            <option></option>
                            @foreach($provinces as $province)
                                <option value="{{$province->id}}" <?=old('province_id') == $province->id ? 'selected' : ''?>>{{$province->name}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <select name="city_id" id="city_id" class="selectpicker" data-width="150"
                                data-toggle="selectpicker"
                                data-nextselect="#district_id"
                                data-refurl="{{url('api/area/areas?id=')}}{value}"
                                data-type="get">
                            <option></option>
                            @foreach($cities as $city)
                                <option value="{{$city->id}}" <?=old('city_id') == $city->id ? 'selected' : ''?>>{{$city->name}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <select name="district_id" id="district_id" class="selectpicker" data-width="150">
                            <option></option>
                            @foreach($districts as $district)
                                <option value="{{$district->id}}" <?=old('district_id') == $district->id ? 'selected' : ''?>>{{$district->name}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">分类</label>

                    <div class="col-sm-2">
                        <select name="p_catalog_id" class="selectpicker" data-width="150" data-toggle="selectpicker"
                                data-nextselect="#catalog_id"
                                data-refurl="{{url('api/catalog/catalogs?id=')}}{value}"
                                data-type="get">
                            <option></option>
                            @foreach($p_catalogs as $p_catalog)
                                <option value="{{$p_catalog->id}}" <?=old('p_catalog_id') == $p_catalog->id ? 'selected' : ''?>>{{$p_catalog->name}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <select name="catalog_id" id="catalog_id" class="selectpicker" data-width="150">
                            <option></option>
                            @foreach($catalogs as $catalog)
                                <option value="{{$catalog->id}}" <?=old('catalog_id') == $catalog->id ? 'selected' : ''?>>{{$catalog->name}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">名称</label>

                    <div class="col-sm-3">
                        <input type="text" name="name" value="{{old('name')}}" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 col-sm-offset-1">
                        <button class="btn btn-primary">查找</button>
                        <a class="btn btn-primary" href="{{url('item')}}">重置</a>
                    </div>
                </div>
            </form>
        </div>
        <div class="panel-body">
            <ul class="list-group">
                @foreach($items as $item)
                    <li class="list-group-item">
                        <h3 class="list-group-item-heading"><a
                                    href="{{url('/item/' . $item->id)}}">{{$item->name}}</a><span class="badge"></span>
                        </h3>

                        <p>{{$item->findLostTime()}} {{$item->address()}}</p>
                        酬金：{{$item->wanted_fee}}元
                        <span class="badge">{{$item->status()}}</span>
                    </li>
                @endforeach
            </ul>
        </div>
    </div>
    <?=$items->render()?>
@endsection